package healthcaresystem;

import java.io.Reader;  //??
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Convert {
/**
 * Convert a String type to a java.sql.Date type
 * @param str 
 * @return corresponding java.sql.Date object
 */
    private static SimpleDateFormat format = new SimpleDateFormat("dd-MMM-yyyy");
    
    public static Date String2Date(String str) {

        Date uDate = null;
        try {
            uDate = format.parse(str);
        } catch (ParseException ex) {
            Logger.getLogger(Reader.class.getName()).log(Level.SEVERE, null, ex);
        }
        java.sql.Date sDate = new java.sql.Date(uDate.getTime());
        return sDate;
    }
    public static String Date2String(Date dd){
        return format.format(dd);
    }
}
